<?php

namespace App\EventSubscriber;

use App\Event\LogDescriptionEvent;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * 日志描述事件订阅-测试使用
 * Class LogDescriptionSubscriber
 * @package App\EventSubscriber
 */
class LogDescriptionSubscriber implements EventSubscriberInterface {

    protected $logger;

    public function __construct (LoggerInterface $logger) {
        $this->logger = $logger;
    }

    /**
     * @inheritDoc
     */
    public static function getSubscribedEvents () {
        return [
            LogDescriptionEvent::NAME => [
                ['onLogDescriptionOne', 10],
                ['onLogDescriptionTwo', 20],
            ],
        ];
    }

    public function onLogDescriptionOne (LogDescriptionEvent $event) {
        $this->logger->info('自定义事件订阅器 one - '.$event->getDescription());
    }

    public function onLogDescriptionTwo (LogDescriptionEvent $event) {
        $this->logger->info('自定义事件订阅器 two - '.$event->getDescription());
    }
}